<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/28/028
 * Time: 15:38
 */

namespace app\api\controller\v1;

use app\api\controller\BaseController;
use app\api\service\NoteCode as NoteCodeService;
use app\lib\exception\SuccessMessage;
use app\api\validate\NoteCodeValidate;
use app\lib\enum\NoteCode as NoteCodeEnum;

class NoteCode extends BaseController {

    /**
     * 发送短信
     * @return array
     */
    public function send_code() {
        file_put_contents(\think\facade\Env::get('root_path') . 'runtime/send_code.txt', json_encode(input('post.')));
        $login_validate = new NoteCodeValidate();
        // 验证参数
        $login_validate->goCheck();
        // 根据验证规则获取参数
        $params = $login_validate->getDataByRule(input('post.'));
        NoteCodeService::send_code($params);
        return json(new SuccessMessage(), 201);
    }
}